<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>项目名称：</label>
                            <input type="text" name="name" placeholder="请输入项目名称"/>
                        </li>
                        <li>
                            <label>项目类型：</label>
                            <div class="col-sm-8">
                                <select name="typeCode" class="form-control m-b">
                                    <option value="">---请选择---</option>
                                    <option th:each="itemType : ${itemTypeList}" th:value="${itemType.code}" th:text="${itemType.name}"></option>
                                </select>
                            </div>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="jiajia:item:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="jiajia:item:edit">-->
            <!--                    <i class="fa fa-edit"></i> 修改-->
            <!--                </a>-->
            <!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="jiajia:item:remove">-->
            <!--                    <i class="fa fa-remove"></i> 删除-->
            <!--                </a>-->
            <!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="jiajia:item:export">-->
            <!--                    <i class="fa fa-download"></i> 导出-->
            <!--                </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('jiajia:item:edit')}]];
    var removeFlag = [[${@permission.hasPermi('jiajia:item:remove')}]];
    var prefix = ctx + "jiajia/item";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "项目",
            columns: [
                {
                    field: 'name',
                    title: '项目信息',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if(row.isShow == 0){
                            actions.push("<span style='color: red'>已下架</span>")
                            actions.push("</br>")
                        }
                        actions.push("类型名称:" + row.typeName)
                        actions.push("</br>")
                        actions.push("项目名称:" + row.name)
                        actions.push("</br>")
                        actions.push("项目描述:" + row.itemDes)
                        actions.push("</br>")
                        actions.push("项目时长:" + row.timeSpan+"分钟")
                        actions.push("</br>")
                        actions.push("销量:" + row.xiaoLiang)
                        actions.push("</br>")
                        actions.push("好评度:" + row.haoPing)
                        actions.push("</br>")
                        actions.push("最低起订时长:"+row.lowest)
                        actions.push("</br>")
                        actions.push("超过最低时长计费标准:" + row.moreThan)
                        return actions.join('');
                    }
                },
                {
                    field: 'workerPercent',
                    title: '分成比例',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push("社工分成比例:" + row.workerPercent+"%")
                        actions.push("</br>")
                        actions.push("平台分成比例:" + row.pingPercent+"%")
                        return actions.join('');
                    }
                },
                {
                    field: 'photo',
                    title: '项目照片',
                    formatter: function (value, row, index) {
                        var actions = [];
                        var url = row.photo;
                        actions.push('<img  src=' + url + ' style="width: 79px;height: 50px;" onclick="onLookPhotoListsClick(' + JSON.stringify(url).replace(/"/g, '&quot;') + ')" />');
                        return actions.join('');
                    }
                },
                {
                    field: 'photoDes',
                    title: '项目详情照片',
                    formatter: function (value, row, index) {
                        var actions = [];
                        var url = row.photoDes;
                        actions.push('<img  src=' + url + ' style="width: 79px;height: 50px;" onclick="onLookPhotoListsClick(' + JSON.stringify(url).replace(/"/g, '&quot;') + ')" />');
                        return actions.join('');
                    }
                },
                {
                    field: 'price',
                    title: '原价',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push("原价:" + row.price)
                        actions.push("</br>")
                        actions.push("现价:" + row.disPrice)
                        return actions.join('');
                    }
                },
                // {
                //     field: 'jieShao',
                //     title: '项目介绍',
                //     formatter: function (value, row, index) {
                //
                //         var actions = [];
                //         actions.push('<a data-toggle="modal" href="#summernote"  data-target="#modal"  onclick="noteClick(\'' + JSON.stringify(row.jieShao).replace(/"/g, '&quot;') + '\')">点击查看</a> ');
                //         return actions.join('');
                //     }
                // },
                // {
                //     field: 'jinJi',
                //     title: '禁忌说明',
                //     formatter: function (value, row, index) {
                //
                //         var actions = [];
                //         actions.push('<a data-toggle="modal" href="#summernote"  data-target="#modal"  onclick="noteClick(\'' + JSON.stringify(row.jinJi).replace(/"/g, '&quot;') + '\')">点击查看</a> ');
                //         return actions.join('');
                //     }
                // },
                // {
                //     field: 'xuZhi',
                //     title: '下单须知',
                //     formatter: function (value, row, index) {
                //         var actions = [];
                //         actions.push('<a data-toggle="modal" href="#summernote"  data-target="#modal"  onclick="noteClick(\'' + JSON.stringify(row.xuZhi).replace(/"/g, '&quot;') + '\')">点击查看</a> ');
                //         return actions.join('');
                //     }
                // },
                {
                    field: 'createTime',
                    title: '添加时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {

                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="onLookDetail(\'' + row.id + '\')">查看明细</a><br><br>');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function onLookPhotoListsClick(url) {
        var data = [];
        var json = {"title": "", "id": 1, "start": 0, "data": data};
        data.push({"alt": "", "pid": 0, "src": url, "thumb": url});

        layer.photos({
            photos: json
            , anim: 5
        });
    }

    // function noteClick(str) {
    //     var actions = [];
    //
    //      var item = JSON.parse(str);
    //      alert(item)
    //     actions.push("<div class=\'summernote\'></div>")
    //     $(".summernote").summernote("editor.insertText", item);
    // }

    function onLookDetail(id) {
        var url = prefix+"/detail/"+id;
        $.modal.open("项目详情", url);
    }

</script>
<!--<script src="/demo/form/summernote"></script>-->
</body>
</html>
